<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/jsp/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>角色新增窗体</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-6">
            <div class="ibox float-e-margins">

                <div class="ibox-content">
                    <form onsubmit="return  false" class="form-horizontal m-t" id="roleForm">
                        <input id="agent_id" value="${role.id}" name="prole.id" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">角色名称：</label>
                            <div class="col-sm-8">
                                <input id="role_name" value="${role.roleName}" name="prole.roleName" class="form-control" type="text" required="" aria-required="true">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">角色分组：</label>
                            <div class="col-sm-8">
                                <select id="role_group" data-placeholder="选择分组..." class="chosen-select" name="prole.roleGroup" class="form-control" style="display: inline-block">
                                    <option value="">请选择分组</option>
                                    <option value="0" >系统组</option>
                                    <option value="1" disabled>其他组</option>
                                </select>

                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">角色备注：</label>
                            <div class="col-sm-8">
                                <textarea id="role_mark" name="prole.roleMark" class="form-control" rows="5"  required="" aria-required="true">${role.roleMark}</textarea>
                            </div>
                        </div>


                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" onclick="doSubmit();">提交</button>
                                <button id="btn_close" class="btn btn-primary" type="button">关闭</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>



<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/validate/jquery.validate.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/chosen/chosen.jquery.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer2.4/layer.js"></script>



<script>
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    //关闭按钮事件
    $('#btn_close').click(function(){
        parent.layer.close(index);
    });

    var group="${role.roleGroup}";
    $("#role_group").val(group);

    function doSubmit()
    {
        var rolename=$("#role_name").val();
        var rolegroup=$("#role_group").val();
        var rolemark=$("#role_mark").val();


        var isOk=true;
        if (rolename == null || rolename == undefined || rolename == '') {
            isOk = false;
        }
        else if (rolegroup == null || rolegroup == undefined || rolegroup == '') {
            parent.layer.msg('请选择权限分组');
            isOk = false;
        }
        else if (rolemark == null || rolemark == undefined || rolemark == '') {
            isOk = false;
        }
        if(isOk){
            $.ajax( {
                url:'${pageContext.request.contextPath}/role/updateRole.ac',// 跳转到 action
                data:$("#roleForm").serialize(),
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data=="success")
                    {
                        parent.layer.msg('修改角色成功');
                        parent.layer.close(index);
                    }else
                    {
                        parent.layer.msg(data);
                    }
                },
                error : function() {
                    parent.layer.msg('"操作失败！');
                }
            });
        }
    }


    $('#role_group').chosen({
        no_results_text : "未找到此选项!",
        width:"100%"
    });

    $("#role_group").trigger("chosen:updated");


</script>
</body>
</html>

